@extends( 'layout.home' )
@section( 'content' )

    <div class="result_wrap">
        <form>
            <table class="add_tab">
                <tbody>
                <tr>
                    <th>车牌号：</th>
                    <td>
                        {{$data['carcity']}} · {{$data['plate_num']}}
                    </td>
                </tr>
                <tr>
                    <th>车类型：</th>
                    <td>
                        @if($data['plate_type'] == 1)
                            小车
                        @elseif($data['plate_type'] == 2)
                            货车/客车
                        @endif
                    </td>
                </tr>
                <tr>
                    <th>停泊类型：</th>
                    <td>
                        @if($data['is_rent']==1)月租车
                        @else 普通车
                        @endif
                    </td>
                </tr>
                <tr>
                    <th>进入时间：</th>
                    <td>
                        {{date('Y-m-d H:i:s',$data['drivein_time'])}}
                    </td>
                </tr>
                <tr>
                    <th>驶出时间：</th>
                    <td>
                        {{date('Y-m-d H:i:s')}}
                    </td>
                </tr>
                <tr>
                    <th>停车时长：</th>
                    <td id="time_diff">
                        {{$data['time_diff']['day']}}天{{$data['time_diff']['hour']}}时{{$data['time_diff']['min']}}分{{$data['time_diff']['sec']}}秒
                    </td>
                </tr>
                @if($data['is_rent']==1)
                @else
                <tr>
                    <th>停车收费：</th>
                    <td>
                        {{$data['charge']}}元
                    </td>
                </tr>
                @endif
                <tr>
                    <th></th>
                    <td>
                        @if($data['is_rent']==1)
                            <input type="button" value="月租车驶出" id="submit">
                        @else
                            <input type="button" value="确认收费" id="submit">
                        @endif
                    </td>
                </tr>
                </tbody>
            </table>
        </form>
    </div>
<script src="https://cdn.bootcss.com/layer/3.1.0/layer.js"></script>
<script>
    $("#submit").click(function(){//点击提交
        var time_diff = $('#time_diff').html();
        $.post("{{url('balance')}}/{{$data['id']}}",{
            '_token':"{{csrf_token()}}",
            'charge':'{{$data['charge']}}',
            'time_diff':time_diff,
            'is_rent':'{{$data['is_rent']}}'
        },function(data){
            if(data.code){
                layer.msg(data.msg);
                setTimeout(function(){  //使用  setTimeout（）方法设定定时2000毫秒
                    var index=parent.layer.getFrameIndex(window.name);
                    window.parent.location.reload();
                    parent.layer.close(index);
                },2000);
            }else{
                layer.msg(data.msg);
            }
        });
    });
</script>

@endsection
